home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / 14 assemblies / assemblydemo / module1.vb < prev   
Encoding:
Text File  |  2002-03-20  |  1.6 KB  |  50 lines

  1. Module MainModule
  2.     Sub Main()
  3.         ' Run one of the Textxxxx procedures below by uncommenting only one statement
  4.  
  5.         'TestExternalAssembly()
  6.         'TestApplicationSettings()
  7.  
  8.         ' You need these statements when running inside Visual Studio, so that
  9.         ' the Console window doesn't disappear
  10.         Console.WriteLine("")
  11.         Console.WriteLine(">>> Press Enter to terminate the program <<<")
  12.         Console.ReadLine()
  13.     End Sub
  14.  
  15.     ' this procedure attempts to run a method of an external assembly
  16.  
  17.     ' IMPORTANT: it requires that you reference the TestAssembly.Dll
  18.     ' project, which will cause the DLL to be copied in the Bin directory
  19.     ' of the current project
  20.  
  21.     Sub TestExternalAssembly()
  22.         Dim vi As New TestAssembly.VersionInfo()
  23.         Console.WriteLine(vi.Description)
  24.     End Sub
  25.  
  26.     ' this procedure reads all application's settings
  27.  
  28.     ' IMPORTANT: This procedure works with the AssemblyDemo.Exe.Config file
  29.     ' provided in this project's directory. This file must be copied in the
  30.     ' Bin subdirectory
  31.  
  32.     Sub TestApplicationSettings()
  33.         Dim colValues As System.Collections.Specialized.NameValueCollection
  34.         Dim key As String
  35.  
  36.         ' retrieve all values as a IDictionary
  37.         colValues = Configuration.ConfigurationSettings.AppSettings()
  38.  
  39.         ' print all values
  40.         For Each key In colValues.AllKeys
  41.             Console.WriteLine("Key=""{0}""  Value=""{1}""", key, colValues.Get(key))
  42.         Next
  43.  
  44.         ' an example of casting to an integer variable
  45.         Dim timeout As Integer = CInt(colValues("Timeout"))
  46.  
  47.     End Sub
  48.  
  49. End Module
  50.